<template>
  <div>
    <div class="maincss">
      <el-row>
        <el-card>
          <el-button class="fr" @click="handleCancel()">提交</el-button>
          <el-button class="fr" @click="handleCancel(1)">取消</el-button>
          <!--          <el-button-->
          <!--            type="warning"-->
          <!--            plain-->
          <!--            icon="el-icon-close"-->
          <!--            size="mini"-->
          <!--            class="fr"-->
          <!--            @click="handleCancel"-->
          <!--          >关闭</el-button>-->
          <el-row class="searchbox">
            <el-col span="1">
              库存盘点
            </el-col>
          </el-row>
          <el-card class="gray-card no-border no-margin-top" shadow="never">
            <el-table
              v-loading="loading"
              :data="checkList"
              style="width: 100%;"
            >
              <el-table-column
                label="耗材编号"
                align="center"
                prop="materialNo"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                label="耗材名称"
                align="center"
                prop="materialName"
                :show-overflow-tooltip="true"
              />
              <el-table-column label="耗材类型" align="center" prop="type" />
              <el-table-column
                label="包装规格"
                align="center"
                prop="packAge"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                label="批号"
                align="center"
                prop="batchNo"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                label="剩余库存数"
                align="center"
                prop="surplus"
              />
              <el-table-column label="实际库存数" align="center" prop="count">
                <input v-model="realityNum" />
              </el-table-column>
              <!--            <el-table-column label="剩余库存数" align="center" prop="isReport" />-->
              <el-table-column
                label="盈亏数量"
                align="center"
                prop="profitLosss"
              />
              <el-table-column label="盈亏原因" align="center" prop="reson">
                <input v-model="summary" />
              </el-table-column>
              <el-table-column label="科室" align="center" prop="deptName" />
              <el-table-column
                label="操作"
                align="center"
                class-name="small-padding fixed-width"
              >
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    @click="handleForceLogout(scope.row)"
                    >删除</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
          </el-card>

          <!--          <pagination v-show="total>0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" />-->
          <div class="pagination-container">
            <el-pagination
              v-show="total > 0"
              background
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              layout="total, sizes,prev, pager, next,jumper"
              :current-page.sync="pageNum"
              :page-size="pageSize"
              :page-sizes="[5, 10, 15, 20]"
              :total="total"
            >
            </el-pagination>
          </div>
        </el-card>
      </el-row>
    </div>
  </div>
</template>

<script>
import {
  delMaterialStore,
  materialStoreList
} from "../../../api/business/materialStore";

export default {
  name: "checkinventory",
  components: {},
  data() {
    return {
      checkList: [],
      loading: false,
      redirect: undefined,
      activeName: "1",
      deviceInfo: {},
      type: [],
      value: "",
      summary: "",
      realityNum: 0,
      total: 5,
      pageNum: 1,
      pageSize: 10
    };
  },
  watch: {},
  created() {
    this.getCheckList();
  },
  methods: {
    getCheckList() {
      let listMaterialForm = {
        pageNum: this.pageNum,
        pageSize: this.pageSize
      };
      this.loading = true;
      materialStoreList(listMaterialForm).then(response => {
        this.loading = false;
        this.checkList = response.rows;
        this.total = response.total;
      });
    },
    toDeviceInfo(id) {
      // this.$router.push({path:"/device/deviceInfo/index"});
    },
    queryListByParams(data) {
      this.checkList = data.rows;
      this.total = data.total;
    },
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getCheckList();
    },
    handleSizeChange(val) {
      this.pageNum = 1;
      this.pageSize = val;
      this.getCheckList();
    },
    handleForceLogout(row) {
      delMaterialStore(row.id).then(response => {
        this.getCheckList();
      });
    },
    handleCancel(data) {
      console.log(data);
      // this.$router.push({path:"/consumable/repertory"})
      this.$store.dispatch("tagsView/delView", this.$route);
      this.$router.push({ path: "/consumable/repertory" });
    }
  }
};
</script>
